<!DOCTYPE HTML>
<html>
<head>
    <title>公共列表页面</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css" />
    <link href="/static/css/default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<#--筛选条件-->
<div class="mini-toolbar" style="padding: 2px; border-bottom: 0;">
    <table style="width: 100%;">
        <tr style="white-space: nowrap;">
            <#if showCheckColumn=='true'>
                <td style="width: 5%;">
            <#else>
                <td style="width: 100%;">
            </#if>
                <#list leftList >
                    <#items as resource>
                        <#switch resource.type >
                            <#case 700>
                                <a class="mini-button" plain="true" iconCls="${resource.icon!''}"
                                   style="width:${resource.width!'120'}px;"
                                        <#if (resource.action)?? && (resource.action) != "" && (resource.action) != " ">
                                            onclick="${resource.action}"
                                        </#if>
                                >${resource.name}</a>
                                <#break>
                            <#case 800>
                                <input name="${resource.field!''}" class="mini-textbox"
                                       emptyText="${resource.prompt!''}"
                                       style="width:${resource.width!150}px;" ${resource.extension!''}/>
                                <#break>
                            <#case 820>
                                <input name="${resource.field!''}" class="mini-combobox"
                                       emptyText="${resource.prompt!''}"
                                       style="width:${resource.width!150}px;" ${resource.extension!''} valueField="id"
                                       textField="text"
                                        <#if (resource.action)?? && (resource.action) != "" && (resource.action) != " ">
                                            url="${resource.action}"
                                        </#if>
                                />
                                <#break>
                            <#case 1100>
                                <input name="${resource.field!''}" class="mini-checkbox" text="${resource.name}"
                                       onvaluechanged="${resource.action!''}" ${resource.extension!''} />
                                <#break>
                            <#case 1200>
                                <input name="${resource.field!''}" class="mini-datepicker"
                                       emptyText="${resource.prompt!''}"
                                       style="width:${resource.width!150}px;" ${resource.extension!''} />
                                <#break>
                            <#default>

                        </#switch>
                    </#items>
                    <span class="separator"></span>

                </#list>
            </td>
            <td style="width: 100%;text-align:left">
                <#if rightList?? && (rightList?size &gt; 0) >
                    <#list rightList>
                        <#items as resource>
                            <#switch resource.type>
                                <#case 800>
                                    <input name="${resource.field!''}" class="mini-textbox"
                                           emptyText="${resource.prompt!''}" style="width:${resource.width!150}px;"
                                           onenter="search" ${resource.extension!''}/>
                                    <#break>
                                <#case 820>
                                    <input name="${resource.field!''}" class="mini-combobox"
                                           emptyText="${resource.prompt!''}"
                                           style="width:${resource.width!150}px;" ${resource.extension!''}
                                           valueField="id" textField="text"
                                            <#if (resource.action)?? && (resource.action) != "" && (resource.action) != " ">
                                                url="${resource.action}&detailid=${resource.detailid!''}"
                                            </#if>
                                    />
                                    <#break>
                                <#case 970>
                                               <idv onclick="itemclick('zm')">
                                                   <input  class="mini-textarea"  name="${resource.field!''}" id="${resource.field!''}" style="width:${resource.width!150}px; height: 22px" readonly="true"   onvaluechanged="onValidation()" textField="codeName" valueField="codeId" emptyText="${resource.prompt!''}"/>
                                               </idv>
                                <br/>
                                    <#break>
                                <#case 50>
                                        <input id="${resource.field!''}" type="text" placeholder="${resource.prompt!''}" style="width:${resource.width!150}px;height: 20px; border: 1px solid; border-color: #e5e4e4" ${resource.extension!''}/>
                                        <#break>
                                <#case 860>
                                    <input name="${resource.field!''}" class="mini-datepicker"
                                           emptyText="${resource.prompt!''}"
                                           style="width:${resource.width!150}px;" ${resource.extension!''} />
                                    <#break>
                                <#case 880>
                                    <#if resource.label?? && resource.label != "" && resource.label != " " >
                                        <label style="font-family: Verdana;">${resource.label}: </label>
                                    </#if>
                                    <input name="${resource.field!''}" class="mini-treeselect"
                                           style="width:${resource.width!150}px;" ${resource.extension!''}
                                           valueField="id" textField="text" multiSelect="false"
                                            <#if (resource.action)?? && (resource.action) != "" && (resource.action) != " ">
                                                url="${resource.action}&detailid=${resource.detailid!''}"
                                            </#if>
                                    />
                                    <#break>
                                <#default>
                            </#switch>
                        </#items>
                    </#list>
                    <#if showCheckColumn=='true'>
                        <#if state??>
                            <#if state=='0'>
                                <span style="position:relative;margin-left:60%;text-align:left">
                                    <a class="mini-button" iconCls="fa fa-search" plain="true" onclick="search">查询</a>
                                <#--做判断-->
                                    <a class="mini-button" iconCls="fa fa-refresh" plain="true" onclick="clear">清除筛选条件</a>
                                </span>
                            <#else>
                                <span style="position:relative;margin-left:70%;text-align:left">
                                    <a class="mini-button" iconCls="fa fa-search" plain="true" onclick="search">查询</a>
                                <#--做判断-->
                                    <a class="mini-button" iconCls="fa fa-refresh" plain="true" onclick="clear">清除筛选条件</a>
                            </span>
                            </#if>

                        <#else >
                            <#if yaz>
                                <span style="margin-left:65%;text-align:left">
                                    <a class="mini-button" iconCls="fa fa-search" plain="true" onclick="search">查询</a>
                                    <a class="mini-button" iconCls="fa fa-refresh" plain="true" onclick="clear">清除筛选条件</a>
                            <#elseif wzf>
                                    <span style="margin-left:64%;text-align:left">
                                    <a class="mini-button" iconCls="fa fa-search" plain="true" onclick="search">查询</a>
                                    <a class="mini-button" iconCls="fa fa-refresh" plain="true" onclick="clear">清除筛选条件</a>
                            <#elseif yzf>
                                    <span style="margin-left:48%;text-align:left">
                                        <a class="mini-button" iconCls="fa fa-search" plain="true" onclick="search">查询</a>
                                        <a class="mini-button" iconCls="fa fa-refresh" plain="true" onclick="clear">清除筛选条件</a>
                                    </span>
                             <#else>
                                    <span style="margin-left:38%;text-align:left">
                                        <a class="mini-button" iconCls="fa fa-search" plain="true" onclick="search">查询</a>
                                        <a class="mini-button" iconCls="fa fa-refresh" plain="true" onclick="clear">清除筛选条件</a>
                                    </span>
                            </#if>
                        </#if>
                    <#else>
                        <span style="margin-right:10px">
                            <a class="mini-button" iconCls="fa fa-search" plain="true" onclick="search">查询</a>
                        <#--做判断-->
                            <a class="mini-button" iconCls="fa fa-refresh" plain="true" onclick="clear">清除筛选条件</a>
                        </span>
                    </#if>

                </#if>
            </td>
        </tr>
    </table>
</div>
<#--筛选条件-->
<div class="mini-fit">
    <#if grid??>
        <div id="datagrid1" class="mini-datagrid" style="width: 100%; height: 100%;"
             ajaxType="get" ${grid.extension!''} sizeList="[50,100,200]" pageSize="50" virtualScroll="false" allowSortColumn="true"
             showLoading="true" allowAlternating="true" multiSelect="true" idField="id" allowCellWrap="true"
                <#if (grid.action)?? && (grid.action) != "" && (grid.action) != " ">
                    url="${grid.action}"
                <#else>
                    url="/aa"
                </#if>
        >
            <#--表格-->
            <#if fieldList?? && (fieldList?size &gt; 0) >
                <div property="columns">
                    <#if showCheckColumn == 'true'>
                        <div type="checkcolumn" class="mini-checkcolumn"></div>
                    </#if>
                    <div type="indexcolumn" width="50px" headerAlign="center">序号</div>
                    <#list fieldList>
                        <#items as resource>
                            <div name="${resource.field}" field="${resource.field}" width="100px" align="center"
                                 sortField="${resource.field}" headerAlign="center" allowSort="true" ${resource.extension!''}>
                                ${resource.name!''}
                               <#-- <#if (resource.action)?? && (resource.action) != "" && (resource.action) != " ">
                                    ${resource.action!''}
                                </#if>-->
                            </div>
                        </#items>
                    </#list>
                    <#list fieldList1>
                        <#items as resource >
                            <div name="${resource.field}" field="${resource.field}" width="280px" align="center"
                                 headerAlign="center" allowSort="false" ${resource.extension!''}>
                                ${resource.name!''}
                                <#-- <#if (resource.action)?? && (resource.action) != "" && (resource.action) != " ">
                                     ${resource.action!''}
                                 </#if>-->
                            </div>
                        </#items>
                    </#list>
                    <#if midList?? && (midList?size &gt; 0) >
                        <div name="action" headerAlign="center" align="center" renderer="onActionRenderer" cellStyle="padding:0;" allowSort="false" width="100px">
                            操作
                        </div>
                    </#if>
                </div>
            </#if>
        </div>
    </#if>
</div>
<script src="/static/js/laydate-public/laydate.js"></script> <!-- 改成你的路径 -->
<script type="text/javascript">
    mini.parse();
    var zmKey = mini.get("zmKey");
    var grid = mini.get("datagrid1");
    if (grid !== undefined) {
        grid.load()
    }
    grid.on('load', function (e) {
        //console.log(e)
        //noDateHint(e.total);
    });

    laydate.render({
            elem: '#rjStartDate' //原判刑期起日(开始)
            ,format: 'yyyy-MM-dd' //可任意组合
            ,range: '~' //或 range: '~' 来自定义分割字符

    });
    laydate.render({
            elem: '#rjEndDate' //原判刑期止日
            ,format: 'yyyy-MM-dd' //可任意组合
            ,range: '~'//或 range: '~' 来自定义分割字符

    });

    $(function (){
        var url = window.location.href;
        mini.parse();
        if(url.indexOf("&zdbjdx") >= 0) {
            search();
        }
        if(url.indexOf("&ldtx") >= 0) {
                var params = {};
                <#if rightList?? && (rightList?size &gt; 0) >
                <#list rightList>
                <#items as resource>
                var key = "${((resource.field!'')?length>0)?string((resource.field!''),'null')}";
                if (key != null) {
                    if(key=='rjStartDate'||key=='rjEndDate'){
                        var inputValue=document.getElementById(""+key);
                        params[key] = inputValue.value;
                    } else{
                        var value = mini.getByName(key).getValue();
                        if (860 == ${resource.type}) {
                            params[key] = mini.formatDate(value, "yyyy-MM-dd HH:mm:ss");
                        } else {
                            params[key] = value;
                        }
                    }
                }
                </#items>
                </#list>
                params['sortField'] = 'releaseDate';
                params['sortOrder'] = 'asc';
                </#if>
                grid.load(params);
        }
    })
    function onValidation() {
        var critypeValue = zmKey.getValue();
        if(critypeValue.length<=2){
            zmKey.setRequired(true);
        }
    }

    /**
     * 给状态列加颜色
     */
    grid.on("drawcell", function(res){
        var record = res.record;
        var field = res.field;
        var value = res.value;
        if (field === "zt" || field === 'xd' || field === 'state' || field === 'spzt' || field === 'finalstate'){
            res.cellStyle = "color: #008c8c;";
        }
    });

    function itemclick(e) {
      zmKey.setRequired(false);
        if(e == 'zm'){
            mini.open({
                url: "/azbj/yazgl/inmates/sentence/zuiming",
                title: "罪名信息",
                width: 800,
                height: 620,
                allowResize: false,
                showCloseButton: false,
                onload: function () {
                },
                ondestroy: function (action) {
                    if (action == "ok") {
                        var iframe = this.getIFrameEl();
                        var data = iframe.contentWindow.GetData(); // 跨页面传值
                        data1 = mini.clone(data);
                        mini.get("zmKey").setValue(data1.codeId);
                        mini.get("zmKey").setText(data1.codeName);
                        onValidation();
                        getParentCodeNames(data1.codeId);
                    }
                }
            });
        }
    }
    function getParentCodeNames(codeIds) {
        if (codeIds != undefined && codeIds != null && codeIds != '') {
            $.ajax({
                url: "/azbj/inmates/sentence/syscode?codeIds=" + codeIds,
                type: 'post',
                async: false,
                success: function (data) {
                    var res = data.data;
                    var name = ''
                    var codeIds=''
                    var nameType='';
                    for (var i = 0; i < res.length; i++) {
                        if (i == 0) {
                            name = res[i].codeName;
                            codeIds = res[i].codeId;
                        } else if(i >0 && i < res.length-1){
                            name = name + ',' + res[i].codeName;
                            codeIds = codeIds + ',' + res[i].codeId;
                        }
                        if(i == res.length-1){
                            nameType = res[i].codeType;
                        }
                    }
                    mini.get("zmKey").setValue(codeIds);
                    mini.get("zmKey").setText(name);
                }
            });
        }

    }

    // 操作按钮对应的方法
    function onActionRenderer(e) {
        var s = "";
        <#if state=="4">//核查失败，操作按钮
            // 从那个核查那里得到的查询出来的数据
            var row1 = e.row;
            <#if midList?? && (midList?size &gt; 0) >
            <#list midList>
            <#items as resource>
            <#if resource.flowid=='1'>//再次发起核查
            if (row1.failurenum == '1' && row1.pushState == '4') {
                s += "&nbsp;<a class=\"mini-button ${resource.icon}\"  name=\"midbtn_${resource.field}\" resid=\"${resource.id?c}\" onclick=\"${(resource.action)}\"  >&nbsp;${resource.name}&nbsp;</a>&nbsp";
            }
            <#elseif resource.flowid=='2'>//转入原侦查机关
            if (row1.failurenum == '2' && row1.pushState == '4') {
                s += "&nbsp;<a class=\"mini-button ${resource.icon}\"  name=\"midbtn_${resource.field}\" resid=\"${resource.id?c}\" onclick=\"${(resource.action)}\"  >&nbsp;${resource.name}&nbsp;</a>&nbsp";
            }
            // 再次发起核查的编辑按钮
            <#elseif resource.flowid=='3'>
            if (row1.failurenum == '1' && row1.pushState == '4') {
                s += "&nbsp;<a class=\"mini-button ${resource.icon}\"  name=\"midbtn_${resource.field}\" resid=\"${resource.id?c}\" onclick=\"${(resource.action)}\"  >&nbsp;${resource.name}&nbsp;</a>&nbsp";
            }
            // 核查失败原因按钮
            <#elseif resource.flowid=='4'>
            s += "&nbsp;<a class=\"mini-button ${resource.icon}\"  name=\"midbtn_${resource.field}\" resid=\"${resource.id?c}\" onclick=\"${(resource.action)}\"  >&nbsp;${resource.name}&nbsp;</a>&nbsp";
            <#else>/*如果不为0且不为1的时候表示显示该按钮*/
            s += "&nbsp;<a class=\"mini-button ${resource.icon}\"  name=\"midbtn_${resource.field}\" resid=\"${resource.id?c}\" onclick=\"${(resource.action)}\"  >&nbsp;${resource.name}&nbsp;</a>&nbsp";
            </#if>
            </#items>
            </#list>
            </#if>
        <#else>
            <#if midList?? && (midList?size &gt; 0) >
            <#list midList>
            <#items as resource>
            s += "&nbsp;<a class=\"mini-button ${resource.icon}\"  name=\"midbtn_${resource.field}\" resid=\"${resource.id?c}\" onclick=\"${(resource.action)}\"  >&nbsp;${resource.name}&nbsp;</a>&nbsp";
            </#items>
            </#list>
            </#if>
        </#if>

        return s;
    }

    function search() {
        var params = {};
        <#if rightList?? && (rightList?size &gt; 0) >
        <#list rightList>
        <#items as resource>
        var key = "${((resource.field!'')?length>0)?string((resource.field!''),'null')}";
        if (key != null) {
            if(key=='rjStartDate'||key=='rjEndDate'){
                var inputValue=document.getElementById(""+key);
                params[key] = inputValue.value;
            }else{
                var value = mini.getByName(key).getValue();
                if (860 == ${resource.type}) {
                    params[key] = mini.formatDate(value, "yyyy-MM-dd HH:mm:ss");
                } else {
                    params[key] = value;
                }
            }
        }
        </#items>
        </#list>
        </#if>
        grid.load(params)
    }
    function clear() {
        var params = {};
        <#if rightList?? && (rightList?size &gt; 0) >
        <#list rightList>
        <#items as resource>
        var key = "${((resource.field!'')?length>0)?string((resource.field!''),'null')}";
        if (key != null) {
            if(key=='rjStartDate'||key=='rjEndDate'){
                var inputValue=document.getElementById(""+key);
                inputValue.value=null;
            }else{
                mini.getByName(key).setValue(null);
            }
        }
        </#items>
        </#list>
        </#if>
        grid.load(params);
    }

    // 点击批量导出按钮
    function plhcWork() {
      var dataLength=grid.data.length;
        var rows = grid.getSelecteds();
        if (rows.length <= 0) {
            if(dataLength<=0){
                mini.alert("该列表无数据！");
            }else {
                mini.confirm("您是否确定导出当前状态所有数据？", "提示",
                    function bbb(action) {
                        if (action == "ok") {
                            window.location.href = encodeURI("/azbj/abwordresource/common/exportExcelFile?type=9");
                            return;
                        }
                    });
            }
        }else{
            mini.confirm("您一共选择:" + rows.length + "条数据,"+"确定导出吗？","提示",
                function aaa(action) {
                    if (action == "ok") {
                        $.post("/azbj/abwordresource/common/exportExcelFile",{maps:JSON.stringify(rows)},function (data,success){
                            if (data.code == 1) {
                                window.location.href = encodeURI("/azbj/abwordresource/common/exportExcelFile?priKey=" + data.data + "&type=0");
                                mini.alert("导出成功");
                                grid.reload();
                            } else {
                                mini.alert("请求失败");
                            }

                        });
                    }
                }
            );
        }
        grid.reload();
    }
</script>
<script src="/static/js/azbj/yazgl/search_code.js" type="text/javascript"></script>
<#if self.outjs?length gt 0>
    <script src="/static/js/${self.outjs}" type="text/javascript"></script>
</#if>
</body>
</html>